#pragma once


#include "Window.h"


namespace Zaf {
namespace Mwl {



class FrameWindow : public Window {

public:
	virtual ~FrameWindow();

	void SetOwner(FrameWindow& owner);

	void Show();
	DWORD ShowModal();
	void EndModal(DWORD dialogResult);

	void Hide();
	void Close();

protected:
	FrameWindow();

	static BOOL CALLBACK OrignalDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

	LRESULT WndProc(const WndMsg& msg);
	LRESULT DefWndProc(const WndMsg& msg);

	virtual BOOL DlgProc(const WndMsg& msg);

private:
	void InitializeFrameWindow(CreatedEventArgs& args);

	bool m_isModal;
	DWORD m_dialogResult;
	HWND m_owner;
};



inline FrameWindow::FrameWindow() : m_owner(NULL), m_dialogResult(0), m_isModal(false) {
	CreatedEvent.Register(this, &FrameWindow::InitializeFrameWindow);
}


inline FrameWindow::~FrameWindow() {

}


inline void FrameWindow::SetOwner(FrameWindow& owner) {
	SetParentOrOwner(owner.GetHandle());
	m_owner = owner.GetHandle();
}


inline void FrameWindow::Show() {
	ShowWindow(GetHandle(), SW_SHOW);
}


inline void FrameWindow::EndModal(DWORD dialogResult) {

	if (m_isModal == true) {
		m_dialogResult = dialogResult;
		PostQuitMessage(0);
	}
}



inline void FrameWindow::Hide() {
	ShowWindow(GetHandle(), SW_HIDE);
}



}
}

